/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.asu.cse360.client.ui.frame;

import edu.asu.cse360.client.context.RestaurantContext;
import edu.asu.cse360.client.util.AppConfiguration;
import edu.asu.cse360.client.util.ChefConfiguration;
import edu.asu.cse360.client.util.ManagerConfiguration;
import edu.asu.cse360.client.util.WaitPersonConfiguration;
import edu.asu.cse360.model.Chef;
import edu.asu.cse360.model.Employee;
import edu.asu.cse360.model.Manager;
import edu.asu.cse360.model.WaitPerson;
import edu.asu.cse360.util.EmployeeVisitor;

/**
 * This class implements the program. This is the one responsible to load the correct frames for the different types of people
 * @author nadimhoque
 */
public class AppInitialization {

    //private static Action loginAction = ;
    private static final EmployeeVisitor configurationVisitor = new EmployeeVisitor(){

        public Object visit(Manager manager) {
            return ManagerConfiguration.instance();
        }

        public Object visit(WaitPerson waitPerson) {
            return WaitPersonConfiguration.instance();
        }

        public Object visit(Chef chef) {
            return ChefConfiguration.instance();
        }
        
    };

    public static void initializeApp(Employee employee){
        setUpRestaurantContext(employee);
        AppConfiguration config = (AppConfiguration) employee.accept(configurationVisitor);
        AppFrame frame = AppFrame.getAppFrame();
        config.configure(frame);
        frame.setVisible(true);
    }

    private static void setUpRestaurantContext(Employee employee) {
        RestaurantContext.setloggedInUser(employee);
        RestaurantContext.setRestaurant(employee.getRestaurant());
        RestaurantContext.setCustomerMode(false);
        RestaurantContext.setTable(null);
    }
    

}
